public class demo20 {
    public int lengthOfLongestSubstring(String ss) {
        char[] s = ss.toCharArray();
        int[] hash = new int[128];
        int left = 0, right = 0;int ret = 0;
        int n = ss.length();
        while(right < n){
            hash[s[right]]++;
            while(hash[s[right]] > 1){
                hash[s[left++]]--;
                ret = Math.max(ret,right-left+1);
                right++;
            }
        }
        return ret;
    }
}
